a11y: Refactor function
authorBenjamin Otte <otte@redhat.com>
Wed, 26 Feb 2014 00:47:50 +0000 (01:47 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 26 Feb 2014 01:36:08 +0000 (02:36 +0100)
Make the intent of the function clear by implementing it that way.

gtk/a11y/gtktreeviewaccessible.c

index 80312da392f260d33fd259299cd57237fe86edf4..6c579b29fe614b1b2857c662e256a901fbb4e2d7 100644 (file)
@@ -378,38 +378,36 @@ create_cell_accessible (GtkTreeView           *treeview,
                         GtkTreeViewAccessible *accessible,
                         GtkTreeViewColumn     *column)
 {
-  AtkObject *parent;
-  GtkContainerCellAccessible *container = NULL;
   GList *renderer_list;
   GList *l;
   GtkCellAccessible *cell;
 
   renderer_list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
 
-  /* If there is not exactly one renderer in the list,
-   * make a container
+  /* If there is exactly one renderer in the list (which is a 
+   * common case), shortcut and don't make a container
    */
-  if (g_list_length (renderer_list) != 1)
+  if (g_list_length (renderer_list) == 1)
     {
-      container = gtk_container_cell_accessible_new ();
-      _gtk_cell_accessible_initialize (GTK_CELL_ACCESSIBLE (container), GTK_WIDGET (treeview), ATK_OBJECT (accessible));
-
-      parent = ATK_OBJECT (container);
+      cell = create_cell_accessible_for_renderer (renderer_list->data, GTK_WIDGET (treeview), ATK_OBJECT (accessible));
     }
   else
-    parent = ATK_OBJECT (accessible);
+    {
+      GtkContainerCellAccessible *container;
+
+      container = gtk_container_cell_accessible_new ();
+      _gtk_cell_accessible_initialize (GTK_CELL_ACCESSIBLE (container), GTK_WIDGET (treeview), ATK_OBJECT (accessible));
 
-  cell = NULL;
+      for (l = renderer_list; l; l = l->next)
+        {
+          cell = create_cell_accessible_for_renderer (l->data, GTK_WIDGET (treeview), ATK_OBJECT (container));
+          gtk_container_cell_accessible_add_child (container, cell);
+        }
 
-  for (l = renderer_list; l; l = l->next)
-    {
-      cell = create_cell_accessible_for_renderer (l->data, GTK_WIDGET (treeview), parent);
-      if (container)
-        gtk_container_cell_accessible_add_child (container, cell);
+      cell = GTK_CELL_ACCESSIBLE (container);
     }
+
   g_list_free (renderer_list);
-  if (container)
-    cell = GTK_CELL_ACCESSIBLE (container);
 
   return cell;
 }